import 'package:du_application/model/GoodsModel.dart';
import 'package:du_application/provide/GoodsProvider.dart';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';

import 'DetailBuyBar.dart';
class DetailSize extends StatelessWidget {
   final List<Attribute> attribute;
  const DetailSize({Key key,this.attribute}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
               Container(
                      padding: EdgeInsets.symmetric(horizontal: 10),
                      margin: EdgeInsets.symmetric(vertical: 5),
                      height: 50,
                      color: Colors.white,
                      child:Provide<GoodsProvider>(
        builder: (context, child,index){
                     return  InkWell(
                       onTap: (){
                            showModalBottomSheet(
                      shape: RoundedRectangleBorder(
                          borderRadius: BorderRadiusDirectional.circular(10)),
                      context: context,
                      builder: (_) {
                        return DetailBuyBar(productList:index.goodsModel.data.productList);
                      });
                       },
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Text("请选择尺码",
                                  style: TextStyle(
                                      color: Colors.grey[600], fontSize: 12)),
                              Row(
                                children: <Widget>[
                                  Text(index.product.specifications.join(),
                                      style: TextStyle(
                                          color: Colors.grey[600], fontSize: 12)),
                                  Icon(
                                    Icons.arrow_forward_ios,
                                    color: Colors.grey[200],
                                    size: 10,
                                  ),
                                ],
                              ),
                            ],
                          )
                        );}) ),
                    Container(
                        // margin: EdgeInsets.symmetric(vertical: 10),
                        padding:attribute.length>0?EdgeInsets.symmetric(horizontal: 15, vertical: 10):EdgeInsets.all(0),
                        color: Colors.white,
                        child: Column(
                          children:attribute.length>0? attribute.map((item){
                          return  Container(
                              padding: EdgeInsets.symmetric(vertical: 5),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: <Widget>[
                                  Text(item.attribute,
                                      style: TextStyle(
                                          color: Colors.grey[600],
                                          fontSize: 12)),
                                  Text(item.value,
                                      style: TextStyle(
                                          color: Colors.grey[600],
                                          fontSize: 12)),
                                ],
                              ),
                            );
                          }).toList():[],
                        ))
        ],
      ),
    );
  }
}